<script setup>
import { PlusOutlined, SearchOutlined, RedoOutlined } from '@ant-design/icons-vue'
import { ref } from 'vue'

const emits = defineEmits(['add', 'init', 'search'])

// 新增按钮点击
const add = () => {
  emits('add')
}
// 刷新
const applyName = ref('')
const phone = ref('')
const typeName = ref(null)
const status = ref(null)
const init = () => {
  applyName.value = ''
  phone.value = ''
  typeName.value = null
  status.value = null
  emits('init')
}
// 搜索
const search = () => {
  emits('search', {
    applyName: applyName.value ?? null,
    phone: phone.value ?? null,
    typeName: typeName.value ?? null,
    status: status.value ?? null
  })
}
</script>

<template>
  <div class="head">
    <div class="left">
      <AButton type="primary" @click="add" v-if="false"> <PlusOutlined /> 新增 </AButton>
    </div>
    <div class="right">
      <a-input
        @input="search"
        v-model:value="applyName"
        placeholder="请输入申请人员查询"
        class="com-ipt"
        allowClear
      >
        <template #suffix>
          <SearchOutlined />
        </template>
      </a-input>
      <a-input
        @input="search"
        v-model:value="phone"
        placeholder="请输入联系电话查询"
        class="com-ipt"
        allowClear
      >
        <template #suffix>
          <SearchOutlined />
        </template>
      </a-input>
      <a-input
        @input="search"
        v-model:value="typeName"
        placeholder="请输入申请类型查询"
        class="com-ipt"
        allowClear
      >
        <template #suffix>
          <SearchOutlined />
        </template>
      </a-input>
      <a-select
        @change="search"
        class="com-ipt"
        placeholder="筛选审批状态"
        v-model:value="status"
        :options="[
          { label: '未审核', value: 0 },
          { label: '审核中', value: 1 },
          { label: '通过', value: 2 },
          { label: '驳回', value: 3 }
        ]"
        allowClear
      />
      <AButton type="primary" @click="search"> <SearchOutlined /> 搜索 </AButton>
      <AButton type="primary" @click="init"> <RedoOutlined /> 刷新 </AButton>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.head {
  display: flex;
  gap: 8px;
  justify-content: space-between;

  .left {
    display: flex;
    align-items: center;
    gap: 8px;

    .total {
      border-left: 3px solid #eee;
      padding-left: 10px;
      font-size: 18px;
      font-weight: bold;
      color: #333;
    }
  }

  .right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
}
</style>